package com.example.smartstart.service.impl;

import com.example.smartstart.entity.Admin;
import com.example.smartstart.mapper.AdminMapper;
import com.example.smartstart.service.IAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.smartstart.utils.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dlx
 * @since 2024-07-22
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin findByUserName(String username) {
        return adminMapper.findByUserName(username);
    }

    @Override
    public void add(String username, String password) {
        String md5String = Md5Util.getMD5String(password);
        Admin admin = new Admin();
        admin.setUsername(username);
        admin.setPassword(md5String);
        adminMapper.insert(admin);
    }
}
